#include <iostream>
#include <vector>

using namespace std;

template<typename T>
void shellSort(vector<T>& arr){
    int n = arr.size();
    for(int gap = n / 2; gap > 0; gap /= 2){
        for(int i = gap; i < n; ++i){
            T temp = arr[i];
            int j;
            for(j = i; j >= gap && arr[j - gap] > temp; j -= gap)
                arr[j] = arr[j - gap];
            arr[j] = temp;
        }
    }
}

int main(){
    vector<int> arr = {3,1,4,5,6,7,9,0};
    shellSort<int>(arr);
    for(int x : arr) cout << x << " ";
    return 0; 
}